# 用户中心

from selenium.webdriver.common.by import By


class PageEcshopFrontUserCenter():
    def __init__(self, driver):
        self.driver = driver

    # 定义定位器
    loc_front_usercenter_welcome_page = (By.XPATH, '//div[@class="userMenu"]/a[1]')
    loc_front_usercenter_information = (By.XPATH, '//div[@class="userMenu"]/a[2]')
    loc_front_usercenter_my_order = (By.XPATH, '//div[@class="userMenu"]/a[3]')
    loc_front_usercenter_shipping_address = (By.XPATH, '//div[@class="userMenu"]/a[4]')
    loc_front_usercenter_my_collection = (By.XPATH, '//div[@class="userMenu"]/a[5]')
    loc_front_usercenter_leave_message = (By.XPATH, '//div[@class="userMenu"]/a[6]')
    loc_front_usercenter_my_hashtag = (By.XPATH, '//div[@class="userMenu"]/a[7]')
    loc_front_usercenter_stock_registration = (By.XPATH, '//div[@class="userMenu"]/a[8]')
    loc_front_usercenter_red_envelope = (By.XPATH, '//div[@class="userMenu"]/a[9]')
    loc_front_usercenter_my_recommendation = (By.XPATH, '//div[@class="userMenu"]/a[10]')
    loc_front_usercenter_my_comment = (By.XPATH, '//div[@class="userMenu"]/a[11]')
    loc_front_usercenter_tracking_parcel = (By.XPATH, '//div[@class="userMenu"]/a[12]')
    loc_front_usercenter_money_management = (By.XPATH, '//div[@class="userMenu"]/a[13]')
    loc_front_cllection_goods = (By.XPATH, '//div[@class="userMenu"]/a[14]')

    # 欢迎页
    def front_usercenter_welcome_page(self):
        handles = self.driver.window_handles
        self.driver.switch_to.window(handles[-1])
        self.driver.find_element(*self.loc_front_usercenter_welcome_page).click()

    # 用户信息
    def front_usercenter_information(self):
        handles = self.driver.window_handles
        self.driver.switch_to.window(handles[-1])
        self.driver.find_element(*self.loc_front_usercenter_information).click()

    # 我的订单
    def front_usercenter_my_order(self):
        handles = self.driver.window_handles
        self.driver.switch_to.window(handles[-1])
        self.driver.find_element(*self.loc_front_usercenter_my_order).click()

    # 收货地址
    def front_usercenter_shipping_address(self):
        self.driver.find_element(*self.loc_front_usercenter_shipping_address).click()
        handles = self.driver.window_handles
        self.driver.switch_to.window(handles[-1])

    # 我的收藏
    def front_usercenter_my_collection(self):
        handles = self.driver.window_handles
        self.driver.switch_to.window(handles[-1])
        self.driver.find_element(*self.loc_front_usercenter_my_collection).click()

    # 我的留言
    def front_usercenter_leave_message(self):
        handles = self.driver.window_handles
        self.driver.switch_to.window(handles[-1])
        self.driver.find_element(*self.loc_front_usercenter_leave_message).click()

    # 我的标签
    def front_usercenter_my_hashtag(self):
        handles = self.driver.window_handles
        self.driver.switch_to.window(handles[-1])
        self.driver.find_element(*self.loc_front_usercenter_my_hashtag).click()

    # 缺货登记
    def front_usercenter_stock_registration(self):
        handles = self.driver.window_handles
        self.driver.switch_to.window(handles[-1])
        self.driver.find_element(*self.loc_front_usercenter_stock_registration).click()

    # 我的红包
    def front_usercenter_red_envelope(self):
        handles = self.driver.window_handles
        self.driver.switch_to.window(handles[-1])
        self.driver.find_element(*self.loc_front_usercenter_red_envelope).click()

    # 我的推荐
    def front_usercenter_my_recommendation(self):
        handles = self.driver.window_handles
        self.driver.switch_to.window(handles[-1])
        self.driver.find_element(*self.loc_front_usercenter_my_recommendation).click()

    # 我的评论
    def front_usercenter_my_comment(self):
        handles = self.driver.window_handles
        self.driver.switch_to.window(handles[-1])
        self.driver.find_element(*self.loc_front_usercenter_my_comment).click()

    # 跟踪包裹
    def front_usercenter_tracking_parcel(self):
        handles = self.driver.window_handles
        self.driver.switch_to.window(handles[-1])
        self.driver.find_element(*self.loc_front_usercenter_tracking_parcel).click()

    # 资金管理
    def front_usercenter_money_management(self):
        handles = self.driver.window_handles
        self.driver.switch_to.window(handles[-1])
        self.driver.find_element(*self.loc_front_usercenter_money_management).click()
